from django.db import models

from apps.users.models import User


class Address(models.Model):
    """用户地址"""
    user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='addresses', verbose_name='用户')
    receiver = models.CharField(max_length=20, verbose_name='收货人')
    mobile = models.CharField(max_length=11, verbose_name='手机')
    province = models.CharField(max_length=20,  verbose_name='省')
    city = models.CharField(max_length=20,  verbose_name='市')
    district = models.CharField(max_length=20,  verbose_name='区')
    place = models.CharField(max_length=50, verbose_name='地址')
    is_deleted = models.BooleanField(default=False, verbose_name='逻辑删除')
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'tb_address'
        verbose_name = '用户地址'
        verbose_name_plural = verbose_name
        ordering = ['-update_time']
